package com.example.fence.mqtt;

import lombok.extern.slf4j.Slf4j;
import org.eclipse.paho.client.mqttv3.*;
import org.eclipse.paho.client.mqttv3.MqttClient;

import javax.annotation.Resource;
import java.time.Instant;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * MQTT消息回调方法
 */
@Slf4j
public class MqttCallBackHandle implements MqttCallbackExtended {


    private MqttClient client;


    public  MqttCallBackHandle(MqttClient client){
        this.client=client;
    }

    //订阅主题
    private final static String CMD_TOP_FORMAT = "+/+/+";


    /**
     * 连接成功后调用该方法
     * @param reconnect
     * @param serverURI
     */
    @Override
    public void connectComplete(boolean reconnect, String serverURI) {
        log.info("=====MQTT重联成功=====");
    }

    /**
     * 断开连接后回调方法
     * @param throwable
     */
    @Override
    public void connectionLost(Throwable throwable) {
        log.info("======MQTT连接断开=====");
    }

    @Override
    public void messageArrived(String topic, MqttMessage message) throws Exception {

    }

    /**
     * 发送完成
     * @param iMqttDeliveryToken
     */
    @Override
    public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) {
    }
}
